// 先双for, 统计不同和的子序列,
// 然后遍历不同和, 每个和对应子序列, 求数量: end 升序, 没有交集, 有交集则弃用
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let n;
let initArr = [];
rl.on("line", (line)=>{
    if(n === undefined) {
        n = Number(line.trim())
    } else {
        initArr = line.trim().split(" ").map(Number)
        console.log(getResult(n, initArr))

        //clear
        n = undefined
        initArr.length = 0
    }

})

function getResult(n, initArr) {
    let obj = {}
    // 双for统计
    for (let i = 0; i < initArr.length ; i++) {
        let temp = 0
        for (let j = i; j < initArr.length ; j++) {
            temp+= initArr[j]
            if(obj[temp]) {
                obj[temp].push([i, j])
            } else {
                obj[temp] = [[i, j]]
            }

        }
    }

    // 遍历每个和的字序列数量, 筛选过滤
    let count = 0
    for (const key of Object.keys(obj)) {
        let arr = obj[key]
        arr.sort((a, b) => a[1] - b[1])
        let before = arr[0]
        let tempCount = 1
        for (let i = 1; i <arr.length ; i++) {
            [a, b] = arr[i]
            if(a <= before[1]){
                continue
            } else {
                tempCount++
                before = arr[i]
            }
        }
        count = Math.max(count, tempCount)
    }
    return count

}